package work;
/*
3) 设计一个汽车类,可以有加速,减速,查看当前时速的方法
 */
public class Work03 {
    public static void main(String[] args) {
        carControl carControl = new carControl();

        carControl.name = "何浩楠的汽车";
        carControl.speedUp(49);
        carControl.speedUp(23);
        carControl.speedShow();

        carControl.speedDown(45);
        carControl.speedShow();
    }

}
class carControl{
    String name;
    private int velocity;

    void speedUp(int variable){
        velocity+=variable;
        System.out.println("汽车加速"+variable);
    }
    void speedDown(int variable){
        velocity-=variable;
        System.out.println("汽车减速"+variable);
    }
    void speedShow(){
        System.out.println("汽车当前时速为："+velocity);
    }


}
